<?php if (isset($this->options)): ?> 
    <?php
    $this->headScript()->appendFile($this->baseUrl() . '/application/modules/Country/externals/scripts/poll.js');
    $poll = $this->poll; 
    
    $viewer = $this->viewer ? $this->viewer : Engine_Api::_()->user()->getViewer();
    $voted = $poll->getUserVoted($viewer,$this->country_id);
    //$moreUrl = $this->url(array('controller' => 'poll', 'action' => 'show-all-option'), 'questionpoll_general', true);
    $this->addHelperPath(APPLICATION_PATH . DS . 'application' . DS . 'libraries' . DS . 'Zend' . DS . 'View' . DS . 'Helper', 'Zend_View_Helper_');    
    $this->addHelperPath(APPLICATION_PATH . DS . 'application' . DS . 'libraries' . DS . 'Engine' . DS . 'View' . DS . 'Helper', 'Engine_View_Helper_');
    $this->addHelperPath(APPLICATION_PATH . DS . 'application' . DS . 'modules' . DS . 'Core' . DS . 'View' . DS . 'Helper', 'Core_View_Helper_');    
    $this->addHelperPath(APPLICATION_PATH . DS . 'application' . DS . 'modules' . DS . 'Questionpoll' . DS . 'View' . DS . 'Helper', 'Questionpoll_View_Helper_');    
    $rand = mt_rand();
    ?> 
    <div class="question_poll_title"> <?php echo $poll->title ?></div>
    <ul class="questionpoll_options" id="questionpoll_feed_<?php echo $poll->getIdentity();?>_<?php echo $rand;?>"<?php echo $this->isFeed ? 'isFeed="1"' : '';?>>
    <?php foreach ($this->options as $option): ?>
        <li>
            <?php 
                  $pollvotecount =  $poll->getVoteCount($this->country_id);
                  $polloptionvotecount = $option->getVoteCount($this->country_id);
            ?>
            
            <div class="options_checkbox" style="width:20px;" onclick="Questionpoll.vote($(this), <?php echo $poll->getIdentity();?>, <?php echo $option->getIdentity();?>, <?php echo $this->show_all ? 1 : 0;?>, <?php echo $viewer->getIdentity() ? 1 : 0;?>,<?php echo $this->country_id?>);">
                <?php if(!$poll->hasVote($viewer->user_id,$this->country_id)) : ?>
                <input type="checkbox" value="<?php echo $option->getIdentity();?>" <?php if (is_array($voted) && in_array($option->getIdentity(), $voted)): ?>checked="checked"<?php endif;?>/>
                <?php endif; ?>
            </div>
            
            <div class="options_content <?php if ($option->getVoteCount($this->country_id)):?>voted<?php endif;?>" <?php if(!$poll->hasVote($viewer->user_id,$this->country_id)) :?> onclick="Questionpoll.vote($(this), <?php echo $poll->getIdentity();?>, <?php echo $option->getIdentity();?>, <?php echo $this->show_all ? 1 : 0;?>, <?php echo $viewer->getIdentity() ? 1 : 0;?>,<?php echo $this->country_id?>);" <?php endif;?>>
                <?php
                $percent = $pollvotecount ? round($polloptionvotecount / $pollvotecount, 2) * 100 : 0;                    
                ?>
                <?php if ($polloptionvotecount && $percent):?><div class="options_content_shade" style="width: <?php echo $percent;?>%;"></div><?php endif; ?>
                <div class="options_content_label"><?php echo $option->getTitle();?></div>
                <div class="options_content_votes"><span class="pad-top"></span><?php echo $this->translate(array("%s vote", "%s votes", $polloptionvotecount),
        $this->locale()->toNumber($polloptionvotecount));?></div>
            </div>
           
        </li>                                    
    <?php endforeach; ?> 
    
    
    </ul>
    
    
<?php endif; ?>